import { NavBar } from "antd-mobile";
import { useNavigate } from "react-router-dom";

interface Props {
  title: string;
  back: boolean;
}

const PageHead = ({ title, back }: Props) => {
  const navigate = useNavigate();

  const backHandle = () => {
    navigate(-1);
  };

  const headCss = {
    backgroundColor: "white",
  };

  return (
    <div style={headCss}>
      <NavBar back={back ? "返回" : null} onBack={backHandle}>
        {title}
      </NavBar>
    </div>
  );
};

export default PageHead;
